package com.bblocks.enums;

import com.bblocks.config.SwaggerDisplayEnum;
import com.bblocks.exception.ServiceException;
import lombok.Getter;

@Getter
@SwaggerDisplayEnum(index = "type", name = "name")
public enum AppTypeEnum {
	Upms(0, "upms"),
	App(1, "app"),



	AppDemo(10, "appdemo"),//demo，数据来源sys_user
	All(-1, "all"),

	;

	private Integer type;
	private String name;

	AppTypeEnum(Integer type, String name) {
		this.type = type;
		this.name = name;
	}


	@Override
	public String toString() {
		return String.valueOf(type) + ":" + name;
	}

	private static AppTypeEnum[] all =  AppTypeEnum.values();
	public static AppTypeEnum getAppTypeEnum(Integer appType) {
		if(appType == null)
			return null;
		for (AppTypeEnum c : all) {
			if (c.getType().equals(appType) ) {
				return c;
			}
		}

		throw new ServiceException("无此app类型："+appType);
	}
}
